package org.jmat.service.impl;

import javax.annotation.Resource;

import org.jmat.domain.dao.PersonDao;
import org.jmat.domain.entities.Person;
import org.jmat.service.PersonManager;
import org.springframework.stereotype.Service;
import org.springframework.transaction.annotation.Propagation;
import org.springframework.transaction.annotation.Transactional;

@Service
public class PersonManagerImpl implements PersonManager {

	@Resource 
	private PersonDao personDao;
	
	@Transactional(propagation=Propagation.REQUIRES_NEW)
	public void createPerson(Person p) {
		this.personDao.createPerson(p);
	}

	@Transactional(propagation=Propagation.REQUIRES_NEW)
	public void deletePerson(Person p) {
		this.personDao.deletePerson(p);
	}

	@Transactional(propagation=Propagation.REQUIRED,readOnly=true)
	public Person findById(Integer id) {
		return this.personDao.findById(id);
	}

}
